/*
 * @Author: MiNine
 * @Date: 2020-09-18 16:57:51
 * @LastEditors: MiNine
 * @LastEditTime: 2020-09-25 11:16:31
 * @Description: 客户
 */
const {
  Schema,
  model
} = require('mongoose');
const {
  getRandom
} = require('../utils/randomStr')

const clientSchema = new Schema({
  //账号
  account: String,
  //密码
  password: String,
  //昵称
  nickName: String,
  //性别
  gender: {
    type: Number,
    default: 2
    /*
      0 : 女
      1 : 男
      2 : 未知
    */
  },
  //是否为推广来源
  isPopularize: {
    type: Boolean,
    default: false
  },
  //所属销售人员ID
  belongAdminId: {
    type: Schema.Types.ObjectId,
    ref: 'Admin'
  },
  //保险订单List
  insureOrdList: [{
    type: Schema.Types.ObjectId,
    ref: 'InsureOrder'
  }],
  //理赔订单List
  claimOrdList: [{
    type: Schema.Types.ObjectId,
    ref: 'ClaimOrder'
  }],
  onceCode: {
    type: String,
    default: getRandom()
  }
}, {
  versionKey: false
})

const Client = model('Client', clientSchema);

module.exports.Client = Client;